package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * 旅游地区
 *
 * @author pengq
 */
@Setter
@Getter
public class Region extends BaseDomain {
    /**
     * 禁用
     */
    public static final int STATE_DISABLE = -1;
    /**
     * 默认
     */
    public static final int STATE_COMMON = 0;
    /**
     * 推荐
     */
    public static final int STATE_HOT = 1;

    /**
     * 名称
     */
    private String name;
    /**
     * 上级地区
     */

    private Region parent;
    /**
     * 状态
     */
    private Integer state = STATE_COMMON;

    public String getJson() {
        Map<String, Object> map = new HashMap<>(10);
        map.put("id", id);
        map.put("name", name);
        if (parent != null) {
            map.put("parentId", parent.getId());
            map.put("parentName", parent.getName());
        }
        map.put("state", state);
        // 将Map集合转换成JSON字符串返回
        return JSON.toJSONString(map);
    }

}